package mode.cloneMode04;
//参考 https://blog.csdn.net/qq_37113604/article/details/81168224
public class CloneDemo {

    public static void main(String[] args) throws CloneNotSupportedException {


        School school1 = new School();
        school1.setSchoolName("实验小学");
        school1.setStuNums(100);

        Student stu1 = new Student();
        stu1.setAge(20);
        stu1.setName("zhangsan");
        stu1.setSex(new StringBuffer("男"));
        school1.setStu(stu1);

        System.out.println("s1: "+school1+" school1的hashcode:"+school1.hashCode()+"  school1中stu1的hashcode:"+school1.getStu().hashCode());

        School school2 = school1.clone();  //调用重写的clone方法，clone出一个新的school---s2

        System.out.println("s2: "+school2+" school2的hashcode:"+school2.hashCode()+" school2中stu1的hashcode:"+school2.getStu().hashCode());
    }

}
